package com.loan.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.loan.common.core.domain.PageQuery;
import com.loan.common.core.page.TableDataInfo;
import com.loan.common.utils.StringUtils;
import com.loan.system.domain.CompanyEntity;
import com.loan.system.domain.IndexApplyProductEntity;
import com.loan.system.mapper.IndexApplyProductMapper;
import com.loan.system.service.IndexApplyProductService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @author shiguang on 2022/9/16 10:18
 */
@Service
@RequiredArgsConstructor
public class IndexApplyProductServiceImpl implements IndexApplyProductService {

    private final IndexApplyProductMapper indexApplyProductMapper;

    @Override
    public TableDataInfo<IndexApplyProductEntity> selectPageList(IndexApplyProductEntity entity, PageQuery pageQuery) {
        Map<String, Object> params = entity.getParams();
        LambdaQueryWrapper<IndexApplyProductEntity> lqw = new LambdaQueryWrapper<IndexApplyProductEntity>();
        Page<IndexApplyProductEntity> page = indexApplyProductMapper.selectPage(pageQuery.build(), lqw);
        return TableDataInfo.build(page);
    }

    @Override
    public IndexApplyProductEntity selectById(Long id) {
        return indexApplyProductMapper.selectById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int add(IndexApplyProductEntity entity) {
        return indexApplyProductMapper.insert(entity);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int update(IndexApplyProductEntity entity) {
        return indexApplyProductMapper.updateById(entity);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteById(Long id) {
        return indexApplyProductMapper.deleteById(id);
    }
}
